티스토리 뷰
api.py
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
app.run(debug=True)
실행하기
$ python api.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
#파이참 사용시 .html 사용으로 rest api test 할 수 있다.
# helloworld.htm
# get
GET localhost:5000/helloworld
출처 : https://jojoldu.tistory.com/266
출처 : https://flask-restful.readthedocs.io/en/latest/quickstart.html#a-minimal-api
'공부합시다 > python' 카테고리의 다른 글
django 모델에서 datetime 한국시간으로 설정하기 (0) | 2020.08.11 |
---|---|
python 에서 oracle 사용하기 (0) | 2020.08.04 |
Python 패키지 의존성 관리 (0) | 2020.06.25 |
Django RESTframework (0) | 2020.06.25 |
댓글
- Total
- Today
- Yesterday
TAG
- Laravel
- redis
- 라라벨
- 테스트_다중트랜잭션
- 정의
- php-laravel
- graphql
- django
- php-composer
- VIM-COMMAND
- graphql-php
- composer-self-update
- php
- 나는욕심쟁이
- session+token authorize
- addMonthWithoutOverflow
- composer-install
- Python
- composite-primarykey
- addMonth
- 둘이상인증한번에사용하기
- POP3
- eloquant
- MySQL
- vim
- laravel-test
- 정규식
- 자바스크립트
- 메일
- exception-test
공지사항